import { UseraddressEntity } from './address';
import { xsEntity } from './commentity';
import { Column, Entity,  ManyToMany,  ManyToOne, OneToMany } from 'typeorm';
import { FriendsEntity } from './friends';
import { GroupEntity } from './group';


/**
 * 描述
 */
@Entity()
export class UserEntity extends xsEntity {
  @Column({ comment: '微信名', default: null })
  name: string;

  @Column({ comment: 'openid', })
  openid: string;

  @Column({ comment: 'session_key', default: null, select: false })
  session_key: string;

  @Column({ comment: 'unionid', default: null, select: false })
  unionid: string;
  @Column({ comment: '密码', default: null, select: false })
  password: string;

  @Column({ comment: '头像', default: null, nullable: true })
  avatar: string;
  @Column({ comment: '手机', default: null, nullable: true, length: 20 })
  phone: string;
  @Column({ comment: '手机', default: 0, })
  status: number;

  @OneToMany(() => UseraddressEntity, photo => photo.userId)
  address: UseraddressEntity[];
  //  每个人都有一个 相册属性   => [  1 , 2 , 3 , 4 , 5 ]


  @ManyToOne(() => FriendsEntity, question => question.user)
  friends: FriendsEntity[];
  @ManyToMany(() => GroupEntity, GroupEntity => GroupEntity.members)
  groupChats: GroupEntity[];
}
